package com.lianjinsu.shop.third.forest;

import com.dtflys.forest.annotation.BaseRequest;
import com.dtflys.forest.annotation.GetRequest;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;

@BaseRequest(baseURL = "${wechat.url.base}")
public interface WechatForestClient {

    @Getter
    @Setter
    class SessionResponse {

        @JsonProperty("session_key")
        private String sessionKey;

        @JsonProperty("unionid")
        private String unionId;

        @JsonProperty("errmsg")
        private String errMsg;

        private String openid;

        @JsonProperty("errcode")
        private Integer errCode;
    }

    @GetRequest("${wechat.url.session}?grant_type=authorization_code&appid=${wechat.applet.appId}&secret=${wechat.applet.secret}&js_code={0}")
    SessionResponse session(String jsCode);
}
